package com.ugrow.Study_System.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.ugrow.Study_System.R;
import com.ugrow.Study_System.bean.Student;

import java.util.List;


public class StudentInfoAdapter extends BaseAdapter {
    private Context mContext;
    private List<Student> mList;

    public StudentInfoAdapter(Context context,List<Student> list) {
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();

    }

    @Override
    public Object getItem(int i) {
//        Student student = mList.get(i);
//        String itemName = student.getName();
//        Toast.makeText(StudentInfoAdapter.this, itemName, Toast.LENGTH_SHORT).show();
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if(view == null){
            view = View.inflate(mContext, R.layout.item_student,null);
        }
        ImageView iconIv = (ImageView) view.findViewById(R.id.item_student_icon_iv);
        TextView nameTv = (TextView) view.findViewById(R.id.item_student_name_tv);
        TextView ageTv = (TextView) view.findViewById(R.id.item_student_age_tv);
        TextView sexTv = (TextView) view.findViewById(R.id.item_student_sex_tv);
        TextView idTv = (TextView) view.findViewById(R.id.item_student_id_tv);
        Student student = mList.get(i);

        iconIv.setImageResource(student.getIcon());
        nameTv.setText("姓名:"+student.getName());
        ageTv.setText("年龄:"+student.getAge());
        sexTv.setText("性别:"+student.getSex());
        idTv.setText("做好:"+student.getId());

        return view;
    }
}
